package com.psdi.element;

import com.psdi.manager.ElementManager;
import com.psdi.manager.LevelSystem;
import com.psdi.window.GameJFrame;

import java.awt.*;

/**
 * 关卡类
 * 用于显示当前游戏的关卡信息
 * 继承自ElementObject类
 */
public class Level extends ElementObject {

    private static int height = 20;
    private static int width = GameJFrame.GAME_WIDTH;

    public Level CreateLevel(){
        this.tag = Tag.LEVEL;
        ElementManager.getINSTANCE().addElement(this);
        return this;
    }

    @Override
    public void show(Graphics g) {
        float fillRatio = (float) LevelSystem.getINSTANCE().getEXP() / LevelSystem.getINSTANCE().getMaxEXP();

        int currentLevel = LevelSystem.getINSTANCE().getLevel();

        g.setColor(Color.BLACK);
        g.drawRect(0, 0, width, height);

        g.setColor(new Color(50, 150, 255));
        int fillWidth = (int) (width * fillRatio);
        g.fillRect(1, 1, fillWidth, 20);

        g.setColor(Color.BLACK);
        g.drawString("Level: " + currentLevel, 5, 15);
        g.setColor(Color.BLACK);
        g.drawString("Level: " + currentLevel, 4, 14);
    }
}
